package com.wisdudu.blank.support.view;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.wisdudu.blank.R;


/**
 * Created by qyf on 2016/5/11.
 */
public abstract class LoadingDialog extends Dialog {

    private final TextView mTextView;

    public LoadingDialog(Context context, String text) {
        super(context, R.style.LoadingDialog);
        setContentView(R.layout.dialog_loading);
        mTextView = (TextView) findViewById(R.id.tv_loading);
        mTextView.setText(text);
        Window window = getWindow();
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.gravity = Gravity.CENTER;
        window.setAttributes(attributes);
    }

    public abstract void cancel();

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        dismiss();
    }
}
